package ua.kpi.ipsa.expert.api.client;

import java.lang.reflect.*;
import java.util.*;

import javax.swing.*;

import ua.kpi.ipsa.expert.api.net.*;

/**
 * 
 * @author doctorpro
 * 
 */
public class ClientFrameManager {

	//
	private ClientMain loginFormFrame;

	//
	private final List<JFrame> slaveFrames = new ArrayList<JFrame>();

	//
	private UsersConsole c;

	/**
	 * 
	 * @param app
	 */
	public ClientFrameManager(ClientMain app) {
		this.loginFormFrame = app;
	}

	/**
	 * 
	 */
	public void ceaseOperations() {
		for (Iterator<JFrame> i = slaveFrames.iterator(); i.hasNext();) {
			i.next().dispose();
		}
		slaveFrames.clear();
		loginFormFrame.setVisible(true);
	}

	/**
	 * 
	 * @return
	 */
	public JFrame createFrame() {
		JFrame result = new JFrame();
		slaveFrames.add(result);
		return result;
	}

	/**
	 * 
	 * @return
	 */
	public void disposeFrame(JFrame frame) {
		slaveFrames.remove(frame);
		frame.dispose();
	}

	public void setUsersConsole(UsersConsole c) {
		this.c = c;
	}

	public UsersConsole getConsole() {
		return c;
	}
}
